import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;



public class DatabaseOperate{
		public static Connection conn;
		public static Statement st;
	    // 创建静态全局变量  	  	      
	    /* 插入数据记录，并输出插入的数据记录数*/  
		public DatabaseOperate(){
			String driver = "com.mysql.jdbc.Driver";//database的driver
			String url = "jdbc:mysql://127.0.0.1:3306/hehe";//数据库的地址
			String user = "root";// mysql的root账户名
			String password = "lzx9480173ly";//mysql的password
			try {			
				Class.forName(driver);//设定database的driver
				conn = DriverManager.getConnection(url, user, password);  //与数据库建立连接
				if (!conn.isClosed()) {
					System.out.println("数据库连接成功...");
				}
				st = conn.createStatement();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	    public void infoinsert(information info) {  
	        try {  
	            String sql = "INSERT INTO information (sNo,isadmin,name,password,amount,Address,Birthday,school,phone,sex,grade,age,likebest)"  
	                    + " VALUES ('"+info.getSno()+"','"+info.getIsadmin()+"','"+info.getName()+"','"+info.getPassword()+"','"+info.getAmount()+"',"+
	            		"'"+info.getAddress()+"','"+info.getBirthday()+"','"+info.getSchool()+"','"+info.getPhone()+"'"+
	            		",'"+info.getSex()+"','"+info.getGrade()+"','"+info.getAge()+"','"+info.getLikebest()+"')";  // 插入数据的sql语句  

	            Statement st = (Statement) conn.createStatement();    // 创建用于执行静态sql语句的Statement对象 
	            int count = st.executeUpdate(sql);  // 执行插入操作的sql语句，并返回插入数据的个数  

	            System.out.println("向information表中插入 " + count + " 条数据"); //输出插入操作的处理结果  
	              
	            conn.close();   //关闭数据库连接  
	              
	        } catch (SQLException e) {  
	            System.out.println("向information表中插入数据失败" + e.getMessage().toString());  
	        }  
	    }
	    public void recommendinsert(Recommend recommend) {  
	        try {  
	            String sql = "INSERT INTO recommend (id,sno,cno,dno)"  
	                    + " VALUES ('"+recommend.getId()+"','"+recommend.getSno()+"','"+recommend.getCno()+"','"+recommend.getDno()+"')";  // 插入数据的sql语句  
	            Statement st = (Statement) conn.createStatement();    // 创建用于执行静态sql语句的Statement对象 
	            int count = st.executeUpdate(sql);  // 执行插入操作的sql语句，并返回插入数据的个数  

	            System.out.println("向recommend表中插入 " + count + " 条数据"); //输出插入操作的处理结果  
	              
	            conn.close();   //关闭数据库连接  
	              
	        } catch (SQLException e) {  
	            System.out.println("向recommend表中插入数据失败" + e.getMessage().toString());  
	        }  
	    }
	    public void dishinsert(Dishes dish) {  
	        try {  
	            String sql = "INSERT INTO dishes (id,dNo,dName,cNo,price,issuan,istian,isla,isma,shicai)"  
	                    + " VALUES ('"+dish.getId()+"','"+dish.getDno()+"','"+dish.getDname()+"','"+dish.getCno()+"',"+
	            		"'"+dish.getPrice()+"','"+dish.getTaste()[0]+"','"+dish.getTaste()[1]+"'"+
	            		",'"+dish.getTaste()[2]+"','"+dish.getTaste()[3]+"','"+dish.getMaterial()+"')";  // 插入数据的sql语句  

	            st = (Statement) conn.createStatement();    // 创建用于执行静态sql语句的Statement对象 
	            int count = st.executeUpdate(sql);  // 执行插入操作的sql语句，并返回插入数据的个数  

	            System.out.println("向dishes表中插入 " + count + " 条数据"); //输出插入操作的处理结果  
	              
	            conn.close();   //关闭数据库连接  
	              
	        } catch (SQLException e) {  
	            System.out.println("向dishes表中插入数据失败" + e.getMessage().toString());  
	        }  
	    }
	    public void actioninsert(PeopleAction action) {  
	        try {  
	            String sql = "INSERT INTO peopleaction (id,sNo,dNo,cNo,initrice,restrice,score,time)"  
	                    + " VALUES ('"+action.getId()+"','"+action.getSno()+"','"+action.getDno()+"','"+action.getCno()+"',"+
	            		"'"+action.getInitrice()+"','"+action.getRestrice()+"','"+action.getScore()+"'"+
	            		",'"+action.getTime()+"')";  // 插入数据的sql语句  

	            st = (Statement) conn.createStatement();    // 创建用于执行静态sql语句的Statement对象 
	            int count = st.executeUpdate(sql);  // 执行插入操作的sql语句，并返回插入数据的个数  

	            System.out.println("向peopleaction表中插入 " + count + " 条数据"); //输出插入操作的处理结果  
	              
	            conn.close();   //关闭数据库连接  
	              
	        } catch (SQLException e) {  
	            System.out.println("向peopleaction表中插入数据失败" + e.getMessage().toString());  
	        }  
	    } 
	    public void windowinsert(Window window) {  
	        try {  
	            String sql = "INSERT INTO window (cNo,cName,picture)"  
	                    + " VALUES ('"+window.getCno()+"','"+window.getCname()+"','"+window.getPicture()+"')";  // 插入数据的sql语句  

	            st = (Statement) conn.createStatement();    // 创建用于执行静态sql语句的Statement对象 
	            int count = st.executeUpdate(sql);  // 执行插入操作的sql语句，并返回插入数据的个数  

	            System.out.println("向window表中插入 " + count + " 条数据"); //输出插入操作的处理结果  
	              
	            conn.close();   //关闭数据库连接  
	              
	        } catch (SQLException e) {  
	            System.out.println("向window表中插入数据失败" + e.getMessage().toString());  
	        }  
	    }
	    public void messageinsert(Message message) {  
	        try {  
	            String sql = "INSERT INTO window (id,title,context,time,sNo)"  
	                    + " VALUES ('"+message.getId()+"','"+message.getTitle()+"','"+
	            		message.getContext()+"','"+message.getTime()+"','"+message.getsNo()+"')";  
	            // 插入数据的sql语句  
	            st = (Statement) conn.createStatement();    // 创建用于执行静态sql语句的Statement对象 
	            int count = st.executeUpdate(sql);  // 执行插入操作的sql语句，并返回插入数据的个数  

	            System.out.println("向message表中插入 " + count + " 条数据"); //输出插入操作的处理结果  
	              
	            conn.close();   //关闭数据库连接  
	              
	        } catch (SQLException e) {  
	            System.out.println("向message表中插入数据失败" + e.getMessage().toString());  
	        }  
	    }
	    /* 更新符合要求的记录，并返回更新的记录数目*/  
	    public void infoupdate(information info) {  
	        try {  
	            String sql = "UPDATE information set isadmin='"+info.getIsadmin()+"',name='"+info.getName()+"',password='"+info.getPassword()+"'"+
	        ",amount='"+info.getAmount()+"',Address='"+info.getAddress()+"',Birthday='"+info.getBirthday()+"',school="+
	         "'"+info.getSchool()+"',phone='"+info.getPhone()+"',sex='"+info.getSex()+"',grade='"+info.getGrade()+
	         "',age='"+info.getAge()+"',likebest='"+info.getLikebest()+"' where sno='"+info.getSno()+"'"; 
	            // 更新数据的sql语句  
	              
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            int count = st.executeUpdate(sql);// 执行更新操作的sql语句，返回更新数据的个数  
	              
	            System.out.println("information表中更新 " + count + " 条数据");      //输出更新操作的处理结果  
	              
	            conn.close();   //关闭数据库连接  
	              
	        } catch (SQLException e) {  
	        	System.out.println(e.toString());
	            System.out.println("information表中更新数据失败");  
	        }  
	    }
	    public void recommendupdate(Recommend reco) {  
	        try {  
	            String sql = "UPDATE recommend set id='"+reco.getId()+"',sno='"+reco.getSno()+"',cno='"+reco.getCno()+"'"+
	        ",dno='"+reco.getDno()+"'"; 
	            // 更新数据的sql语句  
	            
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            int count = st.executeUpdate(sql);// 执行更新操作的sql语句，返回更新数据的个数  
	              
	            System.out.println("recommend表中更新 " + count + " 条数据");      //输出更新操作的处理结果  
	              
	            conn.close();   //关闭数据库连接  
	              
	        } catch (SQLException e) {  
	        	System.out.println(e.toString());
	            System.out.println("recommend表中更新数据失败");  
	        }  
	    }
	    public void dishupdate(Dishes dish) {  
	        try {  
	            String sql = "UPDATE dish set dNo='"+dish.getDno()+"'"+
	        ",dName='"+dish.getDname()+"',cNo='"+dish.getCno()+"',price='"+dish.getPrice()+"',issuan='"+
	        dish.getTaste()[0]+"',istian='"+dish.getTaste()[1]+"',isla='"+dish.getTaste()[2]+"',isma='"+
	        dish.getTaste()[3]+"',shicai='"+dish.getMaterial()+"' where id='"+dish.getId()+"'"; 
	            // 更新数据的sql语句  
	              
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            int count = st.executeUpdate(sql);// 执行更新操作的sql语句，返回更新数据的个数  
	              
	            System.out.println("dishes表中更新 " + count + " 条数据");      //输出更新操作的处理结果  
	              
	            conn.close();   //关闭数据库连接  
	              
	        } catch (SQLException e) {
	        	System.out.println("dishes表中更新数据失败"+e.toString());  
	        }  
	    }  
	    public void actionupdate(PeopleAction action) {  
	        try {  
	            String sql = "UPDATE peopleaction set sNo='"+action.getSno()+"'"+
	        ",dNo='"+action.getDno()+"',cNo='"+action.getCno()+"',initrice='"+action.getInitrice()+"',restrice='"+
	        action.getRestrice()+"',score='"+action.getScore()+"',time='"+action.getTime()+"' where id='"+action.getId()+"'"; 
	            // 更新数据的sql语句  
	              
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            int count = st.executeUpdate(sql);// 执行更新操作的sql语句，返回更新数据的个数  
	              
	            System.out.println("peopleaction表中更新 " + count + " 条数据");      //输出更新操作的处理结果  
	              
	            conn.close();   //关闭数据库连接  
	              
	        } catch (SQLException e) {
	        	System.out.println("peopleaction表中更新数据失败"+e.toString());  
	        }  
	    } 
	    public void windowupdate(Window window) {  
	        try {  
	            String sql = "UPDATE window set cName='"+window.getCname()+"',Picture='"+window.getPicture()+"' where cNo='"+window.getCno()+"'"; 
	            // 更新数据的sql语句  
	              
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            int count = st.executeUpdate(sql);// 执行更新操作的sql语句，返回更新数据的个数  
	              
	            System.out.println("window表中更新 " + count + " 条数据");      //输出更新操作的处理结果  
	              
	            conn.close();   //关闭数据库连接  
	              
	        } catch (SQLException e) {
	        	System.out.println("window表中更新数据失败"+e.toString());  
	        }  
	    }
	    public void messageupdate(Message message) {  
	        try {  
	            String sql = "UPDATE message set title='"+message.getTitle()+"',context='"+
	            message.getContext()+"',time='"+message.getTime()+"',sNo='"+message.getsNo()+
	            "' where id='"+message.getId()+"'"; 
	            // 更新数据的sql语句  
	              
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            int count = st.executeUpdate(sql);// 执行更新操作的sql语句，返回更新数据的个数  
	              
	            System.out.println("message表中更新 " + count + " 条数据");      //输出更新操作的处理结果  
	              
	            conn.close();   //关闭数据库连接  
	              
	        } catch (SQLException e) {
	        	System.out.println("message表中更新数据失败"+e.toString());  
	        }  
	    }
	    /* 查询数据库，输出符合要求的记录的情况*/  
	    public ArrayList<information> infoquery(String type,String typeNo) {
	    	ArrayList<information> infolist=new ArrayList<information>();
	        try {  
	            String sql = "select * from information where "+type+"="+typeNo;     // 查询数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            ResultSet rs = st.executeQuery(sql);    //执行sql查询语句，返回查询数据的结果集  
	            while (rs.next()) { // 判断是否还有下一个数据  
	                // 根据字段名获取相应的值  
	    	        information info=new information();
	                info.setSno(rs.getString("sno"));
	                info.setIsadmin(rs.getInt("isadmin"));
	                info.setName(rs.getString("name"));  
	                info.setPassword(rs.getString("password"));
	                info.setAmount(rs.getInt("amount"));
	                info.setAddress(rs.getString("address"));  
	                info.setBirthday(rs.getString("Birthday"));               
	                info.setSchool(rs.getString("school"));
	                info.setPhone(rs.getString("phone"));
	                info.setSex(rs.getString("sex"));
	                info.setGrade(rs.getString("grade"));
	                info.setAge(rs.getInt("age"));
	                info.setLikebest(rs.getString("likebest"));
	                infolist.add(info);
	            }  
	            conn.close();   //关闭数据库连接  
	            return infolist;
	        } catch (SQLException e) {  
	            System.out.println("根据"+typeNo+"查询infomation数据失败"+e.toString());  
	        }
			return null;
	    }
	    public ArrayList<information> infoquery() {
	    	ArrayList<information> infolist=new ArrayList<information>();
	        try {  
	            String sql = "select * from information";     // 查询数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            ResultSet rs = st.executeQuery(sql);    //执行sql查询语句，返回查询数据的结果集  
	            while (rs.next()) { // 判断是否还有下一个数据  
	                // 根据字段名获取相应的值  
	    	        information info=new information();
	                info.setSno(rs.getString("sno"));
	                info.setIsadmin(rs.getInt("isadmin"));
	                info.setName(rs.getString("name"));  
	                info.setPassword(rs.getString("password"));
	                info.setAmount(rs.getInt("amount"));
	                info.setAddress(rs.getString("address"));  
	                info.setBirthday(rs.getString("Birthday"));               
	                info.setSchool(rs.getString("school"));
	                info.setPhone(rs.getString("phone"));
	                info.setSex(rs.getString("sex"));
	                info.setGrade(rs.getString("grade"));
	                info.setAge(rs.getInt("age"));
	                info.setLikebest(rs.getString("likebest"));
	                infolist.add(info);
	            }  
	            conn.close();   //关闭数据库连接  
	            return infolist;
	        } catch (SQLException e) {  
	            System.out.println("查询infomation数据失败"+e.toString());  
	        }
			return null;
	    }
	    public ArrayList<Recommend> recommendquery(String type,String typeNo) {
	    	ArrayList<Recommend> recolist=new ArrayList<Recommend>();
	        try {  
	            String sql = "select * from recommend where "+type+"="+typeNo;     // 查询数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            ResultSet rs = st.executeQuery(sql);    //执行sql查询语句，返回查询数据的结果集  
	            while (rs.next()) { // 判断是否还有下一个数据  
	                // 根据字段名获取相应的值  
	    	        Recommend reco=new Recommend();
	                reco.setId(rs.getInt("id"));
	                reco.setSno(rs.getString("sno"));
	                reco.setCno(rs.getString("cno"));
	                reco.setDno(rs.getString("dno"));  
	                recolist.add(reco);
	            }  
	            conn.close();   //关闭数据库连接  
	            return recolist;
	        } catch (SQLException e) {  
	            System.out.println("根据"+typeNo+"查询recommend数据失败"+e.toString());  
	        }
			return null;
	    }
	    public ArrayList<Recommend> recommendquery() {
	    	ArrayList<Recommend> recolist=new ArrayList<Recommend>();
	        try {  
	            String sql = "select * from recommend";     // 查询数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            ResultSet rs = st.executeQuery(sql);    //执行sql查询语句，返回查询数据的结果集  
	            while (rs.next()) { // 判断是否还有下一个数据  
	                // 根据字段名获取相应的值  
	    	        Recommend reco=new Recommend();
	                reco.setId(rs.getInt("id"));
	                reco.setSno(rs.getString("sno"));
	                reco.setCno(rs.getString("cno"));
	                reco.setDno(rs.getString("dno"));  
	                recolist.add(reco);
	            }  
	            conn.close();   //关闭数据库连接  
	            return recolist;
	        } catch (SQLException e) {  
	            System.out.println("查询recommend数据失败"+e.toString());  
	        }
			return null;
	    }
	    public ArrayList<Dishes> dishquery(String type,String typeNo) {
	    	//type指数据库里的栏目，比如sNo,typeNo指具体值，比如2012212025
	    	ArrayList<Dishes> dishlist=new ArrayList<Dishes>();
	        try {  
	            String sql = "select * from dishes where "+type+"="+typeNo;     // 查询数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	            ResultSet rs = st.executeQuery(sql);    //执行sql查询语句，返回查询数据的结果集  
	            while (rs.next()) { // 判断是否还有下一个数据  
	                // 根据字段名获取相应的值  
	    	        Dishes dish=new Dishes();
	                dish.setId(rs.getInt("id"));  
	                dish.setDno(rs.getString("dNo"));  
	                dish.setDname(rs.getString("dName"));
	                dish.setCno(rs.getString("cNo"));
	                dish.setPrice(rs.getInt("price"));                 
	                dish.setTaste(rs.getInt("issuan"),rs.getInt("istian"),rs.getInt("isla"),rs.getInt("isma"));
	                dish.setMaterial(rs.getString("shicai"));
	                dishlist.add(dish);
	            }  
	            conn.close();   //关闭数据库连接  
	            return dishlist;
	        } catch (SQLException e) {  
	            System.out.println("根据"+typeNo+"查询dishes数据失败"+e.toString());  
	        }
			return null;
	    }
	    public ArrayList<Dishes> dishquery() {//返回整个菜列表
	    	ArrayList<Dishes> dishlist=new ArrayList<Dishes>();
	        try {  
	            String sql = "select * from dishes";     // 查询数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	            ResultSet rs = st.executeQuery(sql);    //执行sql查询语句，返回查询数据的结果集  
	            while (rs.next()) { // 判断是否还有下一个数据  
	                // 根据字段名获取相应的值  
	            	Dishes dish=new Dishes();
	                dish.setId(rs.getInt("id"));  
	                dish.setDno(rs.getString("dNo"));  
	                dish.setDname(rs.getString("dName"));
	                dish.setCno(rs.getString("cNo"));
	                dish.setPrice(rs.getInt("price"));                 
	                dish.setTaste(rs.getInt("issuan"),rs.getInt("istian"),rs.getInt("isla"),rs.getInt("isma"));
	                dish.setMaterial(rs.getString("shicai"));
	                dishlist.add(dish);
	            }  
	            conn.close();   //关闭数据库连接  
	            return dishlist;
	        } catch (SQLException e) {  
	            System.out.println("查询dishes数据失败"+e.toString());  
	        }
			return null;
	    }
	    public ArrayList<PeopleAction> actionquery(String type,String typeNo) {  
	        ArrayList<PeopleAction> actionlist=new ArrayList<PeopleAction>();
	        try {  
	            String sql = "select * from peopleaction where "+type+"="+typeNo;     // 查询数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            ResultSet rs = st.executeQuery(sql);    //执行sql查询语句，返回查询数据的结果集  
	            while (rs.next()) { // 判断是否还有下一个数据  
	                // 根据字段名获取相应的值  
	    	        PeopleAction action=new PeopleAction();
	                action.setId(rs.getInt("id"));  
	                action.setSno(rs.getString("sNo"));  
	                action.setDno(rs.getString("dNo"));
	                action.setCno(rs.getString("cNo"));
	                action.setInitrice(rs.getInt("initrice"));                 
	                action.setRestrice(rs.getInt("restrice"));
	                action.setScore(rs.getInt("score"));
	                action.setTime(rs.getTimestamp("time"));
	                actionlist.add(action);
	            }  
	            conn.close();   //关闭数据库连接
	            return actionlist;
	        } catch (SQLException e) {  
	            System.out.println("根据"+typeNo+"查询peopleaction数据失败"+e.toString());  
	        }
			return null;
	    }
	    public ArrayList<PeopleAction> sevenquery() {
			 java.util.Locale locale=java.util.Locale.CHINA; //这是获得本地中国时区
			 String pattern = "yyyy-MM-dd HH:mm:ss";//这是日期格式
			 java.text.SimpleDateFormat df = new java.text.SimpleDateFormat(pattern,locale);
			 java.util.Date date = new java.util.Date(System.currentTimeMillis()-604800000);
			 String bjTime = df.format(date);
			 System.out.println(bjTime);
			 ArrayList<PeopleAction> actionlist=new ArrayList<PeopleAction>();
			 try {  
	            String sql = "select * from peopleaction where time > '"+bjTime+"'";// 查询数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	            ResultSet rs = st.executeQuery(sql);    //执行sql查询语句，返回查询数据的结果集  
	            while (rs.next()) { // 判断是否还有下一个数据  
	                // 根据字段名获取相应的值  
	    	        PeopleAction action=new PeopleAction();
	                action.setId(rs.getInt("id"));  
	                action.setSno(rs.getString("sNo"));  
	                action.setDno(rs.getString("dNo"));
	                action.setCno(rs.getString("cNo"));
	                action.setInitrice(rs.getInt("initrice"));                 
	                action.setRestrice(rs.getInt("restrice"));
	                action.setScore(rs.getInt("score"));
	                action.setTime(rs.getTimestamp("time"));
	                actionlist.add(action);
	            }  
	            conn.close();   //关闭数据库连接
				System.out.println(actionlist.size());
	            return actionlist;
	        } catch (SQLException e) {  
	            System.out.println("查询七天内peopleaction数据失败"+e.toString());  
	        }
			return null;
	    }
	    public ArrayList<PeopleAction> actionquery() {  
	        ArrayList<PeopleAction> actionlist=new ArrayList<PeopleAction>();  
	        try {  
	            String sql = "select * from peopleaction";     // 查询数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量   
	            ResultSet rs = st.executeQuery(sql);    //执行sql查询语句，返回查询数据的结果集  
	            while (rs.next()) { // 判断是否还有下一个数据  
	                // 根据字段名获取相应的值  
	            	PeopleAction action=new PeopleAction();
	                action.setId(rs.getInt("id"));  
	                action.setSno(rs.getString("sNo"));  
	                action.setDno(rs.getString("dNo"));
	                action.setCno(rs.getString("cNo"));
	                action.setInitrice(rs.getInt("initrice"));                 
	                action.setRestrice(rs.getInt("restrice"));
	                action.setScore(rs.getInt("score"));
	                action.setTime(rs.getTimestamp("time"));
	                actionlist.add(action);
	            }  
	            conn.close();   //关闭数据库连接
	            return actionlist;
	        } catch (SQLException e) {  
	            System.out.println("查询peopleaction数据失败"+e.toString());  
	        }
			return null;
	    }
	    public ArrayList<Window> windowquery(String type,String typeNo) {  
	        ArrayList<Window> windowlist=new ArrayList<Window>();
	        try {  
	            String sql = "select * from window where "+type+"="+typeNo;     // 查询数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            ResultSet rs = st.executeQuery(sql);    //执行sql查询语句，返回查询数据的结果集  
	            while (rs.next()) { // 判断是否还有下一个数据  
	                // 根据字段名获取相应的值  
	    	        Window window=new Window();
	                window.setCno(rs.getString("cNo"));  
	                window.setCname(rs.getString("cName"));  
	                window.setPicture(rs.getString("picture"));
	                windowlist.add(window);
	            }  
	            conn.close();   //关闭数据库连接
	            return windowlist;
	        } catch (SQLException e) {  
	            System.out.println("根据"+typeNo+"查询window数据失败"+e.toString());  
	        }
			return null;
	    }
	    public ArrayList<Window> windowquery() {  
	        ArrayList<Window> windowlist=new ArrayList<Window>();
	        try {  
	            String sql = "select * from window";     // 查询数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            ResultSet rs = st.executeQuery(sql);    //执行sql查询语句，返回查询数据的结果集  
	            while (rs.next()) { // 判断是否还有下一个数据  
	                // 根据字段名获取相应的值  
	    	        Window window=new Window();
	                window.setCno(rs.getString("cNo"));  
	                window.setCname(rs.getString("cName"));  
	                window.setPicture(rs.getString("picture"));
	                windowlist.add(window);
	            }  
	            conn.close();   //关闭数据库连接
	            return windowlist;
	        } catch (SQLException e) {  
	            System.out.println("查询window数据失败"+e.toString());  
	        }
			return null;
	    }
	    public ArrayList<Message> messagequery(String type,String typeNo) {  
	        ArrayList<Message> messagelist=new ArrayList<Message>();
	        try {  
	            String sql = "select * from window where "+type+"="+typeNo;     // 查询数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            ResultSet rs = st.executeQuery(sql);    //执行sql查询语句，返回查询数据的结果集  
	            while (rs.next()) { // 判断是否还有下一个数据  
	                // 根据字段名获取相应的值  
	    	        Message message=new Message();
	                message.setId(rs.getInt("id"));  
	                message.setTitle(rs.getString("title"));  
	                message.setTime(rs.getTimestamp("time"));
	                message.setsNo(rs.getString("sNo"));
	                messagelist.add(message);
	            }  
	            conn.close();   //关闭数据库连接
	            return messagelist;
	        } catch (SQLException e) {  
	            System.out.println("根据"+typeNo+"查询message数据失败"+e.toString());  
	        }
			return null;
	    }
	    public ArrayList<Message> messagequery() {  
	        ArrayList<Message> messagelist=new ArrayList<Message>();
	        try {  
	            String sql = "select * from message";     // 查询数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            ResultSet rs = st.executeQuery(sql);    //执行sql查询语句，返回查询数据的结果集  
	            while (rs.next()) { // 判断是否还有下一个数据  
	                // 根据字段名获取相应的值  
	    	        Message message=new Message();
	                message.setId(rs.getInt("id"));  
	                message.setTitle(rs.getString("title"));  
	                message.setTime(rs.getTimestamp("time"));
	                message.setsNo(rs.getString("sNo"));
	                messagelist.add(message);
	            }  
	            conn.close();   //关闭数据库连接
	            return messagelist;
	        } catch (SQLException e) {  
	            System.out.println("查询message数据失败"+e.toString());  
	        }
			return null;
	    }
	    /* 删除符合要求的记录，输出情况*/  
	    public void infodelete(String sno) {  
	  
	        try {  
	            String sql = "delete from information  where sno="+sno+"";  // 删除数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            int count = st.executeUpdate(sql);// 执行sql删除语句，返回删除数据的数量  
	              
	            System.out.println("infomation表中删除 " + count + " 条数据\n");    //输出删除操作的处理结果  
	              
	            conn.close();   //关闭数据库连接  
	              
	        } catch (SQLException e) {  
	            System.out.println("删除information数据失败");  
	        }  
	    }  
	    public void recommenddelete(String sno) {  
	  	  
	        try {  
	            String sql = "delete from recommend where sno="+sno+"";  // 删除数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            int count = st.executeUpdate(sql);// 执行sql删除语句，返回删除数据的数量  
	              
	            System.out.println("recommend表中删除 " + count + " 条数据\n");    //输出删除操作的处理结果  
	              
	            conn.close();   //关闭数据库连接  
	              
	        } catch (SQLException e) {  
	            System.out.println("删除recommend数据失败");  
	        }  
	    } 
	    public void dishdelete(int id) {  
	        try {  
	            String sql = "delete from dishes  where id="+id;  // 删除数据的sql语句   
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  	            
	            int count = st.executeUpdate(sql);// 执行sql删除语句，返回删除数据的数量  
	            System.out.println("dishes表中删除 " + count + " 条数据\n");    //输出删除操作的处理结果                
	            conn.close();   //关闭数据库连接  	              
	        } catch (SQLException e) {  
	            System.out.println("删除dishes数据失败");  
	        }  
	    } 
	    public void actiondelete(int id) {  
		  	  
	        try {  
	            String sql = "delete from peopleaction  where id="+id;  // 删除数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	            int count = st.executeUpdate(sql);// 执行sql删除语句，返回删除数据的数量
	            System.out.println("peopleaction表中删除 " + count + " 条数据\n");    //输出删除操作的处理结果  
	            conn.close();   //关闭数据库连接  
	        } catch (SQLException e) {  
	            System.out.println("删除peopleaction数据失败");  
	        }   
	    }
	    public void windowdelete(String cNo) {  
		  	  
	        try {  
	            String sql = "delete from window  where cNo="+cNo;  // 删除数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            int count = st.executeUpdate(sql);// 执行sql删除语句，返回删除数据的数量  
	              
	            System.out.println("window表中删除 " + count + " 条数据\n");    //输出删除操作的处理结果  
	              
	            conn.close();   //关闭数据库连接  
	              
	        } catch (SQLException e) {  
	            System.out.println("删除window数据失败");  
	        }  
	    }
	    public void messagedelete(int id) {  
		  	  
	        try {  
	            String sql = "delete from message  where id="+id;  // 删除数据的sql语句  
	            st = (Statement) conn.createStatement();    //创建用于执行静态sql语句的Statement对象，st属局部变量  
	              
	            int count = st.executeUpdate(sql);// 执行sql删除语句，返回删除数据的数量  
	              
	            System.out.println("message表中删除 " + count + " 条数据\n");    //输出删除操作的处理结果  
	              
	            conn.close();   //关闭数据库连接  
	              
	        } catch (SQLException e) {  
	            System.out.println("删除message数据失败");  
	        }  
	          
	    }
	    public static void main(String[] args){
	    	new DatabaseOperate().sevenquery();
	    }
}
